package com.qcxk.yuqian.system.component.exception;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;

@Data
public class ResultBean {

    private String code;
    private String msg;
    private Object data;

    private ResultBean() {

    }

    public static JSONObject error(String message) {
        ResultBean resultBean = new ResultBean();
        resultBean.setCode("1");
        resultBean.setMsg(message);
        return (JSONObject) JSON.toJSON(resultBean);
    }

    public static JSONObject success() {
        ResultBean resultBean = new ResultBean();
        resultBean.setCode("0");
        resultBean.setMsg("success");
        return (JSONObject) JSON.toJSON(resultBean);
    }

    public static JSONObject success(Object data) {
        ResultBean resultBean = new ResultBean();
        resultBean.setCode("0");
        resultBean.setMsg("success");
        resultBean.setData(data);
        JSONObject o = (JSONObject) (JSON.toJSON(resultBean));
        System.out.println(o.toJSONString());
        return (JSONObject) JSON.toJSON(resultBean);
    }

}
